package com.fer.tankr.models;

import org.andengine.entity.primitive.Rectangle;
import org.andengine.extension.physics.box2d.PhysicsFactory;
import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.fer.andenginemvc.api.gameObjects.GameObject;

public class Bullet extends GameObject<Rectangle>{

	
	public Bullet(PhysicsWorld world, VertexBufferObjectManager vbom, float x, float y) {
		super(world, vbom, new Rectangle(x-2,y-2, 4, 4, vbom));
		entity.setColor(0,0,0);
		
	}


	public void setInitPos(float x, float y)
	{
		this.entity.setX(x+entity.getWidth()/2);
		this.entity.setY(y+entity.getHeight()/2);
	}

	public void setDirection(Vector2 v)
	{
		this.body.setLinearVelocity(v.mul(10));
	}

	@Override
	public FixtureDef initFixtureDef() {
		return PhysicsFactory.createFixtureDef(1f, 1f, 1f);
	}

	@Override
	public void onCollision(GameObject<?> go) {
		die();
	}
}
